Namespace Controls

    <Serializable(), ObfuscationAttribute(Exclude:=True, ApplyToMembers:=True)> _
    Public Class BarContainerSettingCollection
        Inherits KeyedCollectionWithEvents(Of String, BarContainerSetting)

        Private mUpdateRate As UInt16 = 500

        Sub New()
        End Sub

        Protected Overrides Function GetKeyForItem(ByVal item As BarContainerSetting) As String
            Return item.Name
        End Function

        Overloads Sub CopyTo(ByVal collection As BarContainerSettingCollection)
            If Me.Count > 0 Then
                For Each item As BarContainerSetting In Me
                    If collection.Contains(item.Name) Then
                        collection.Remove(item.Name)
                    End If
                    collection.Add(item)
                Next
            End If
        End Sub

        Public Property UpdateRate() As UInt16
            Get
                Return mUpdateRate
            End Get
            Set(ByVal value As UInt16)
                mUpdateRate = value
            End Set
        End Property

#Region "Serialization functions"
        Sub New(ByVal Info As Runtime.Serialization.SerializationInfo, ByVal context As Runtime.Serialization.StreamingContext)
            MyBase.New(Info, context)

            Info.AddValue("mUpdateRate", mUpdateRate, mUpdateRate.GetType)
        End Sub

        Public Overrides Sub GetObjectDataAdditionalSerialization(ByVal info As System.Runtime.Serialization.SerializationInfo, ByVal context As System.Runtime.Serialization.StreamingContext)

        End Sub

        Public Overrides Sub NewAdditionalDeserialization(ByVal Info As System.Runtime.Serialization.SerializationInfo, ByVal context As System.Runtime.Serialization.StreamingContext)
            Try
                mUpdateRate = Info.GetUInt32("mUpdateRate")
            Catch ex As Exception
                mUpdateRate = 500
            End Try
        End Sub

#End Region
    End Class
End Namespace
